package lesson02;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestText01  {
    public static void main(String[] args) {
    new MyFrame03();
    }
}
class MyFrame03 extends Frame{
    public  MyFrame03(){
        TextField textfield=new TextField();
        this.add(textfield);
        //监听这个文本框输入的文字
        MyActionListener2 myactionlistener2=new MyActionListener2();
        //按下enter，就会触发这个输入框的时间
        textfield.addActionListener(myactionlistener2);

        textfield.setEchoChar('*');
        this.setVisible(true);
        this.pack();

    }
}
class MyActionListener2 implements ActionListener{

    @Override
    public void actionPerformed(ActionEvent e) {
        TextField field=(TextField)e.getSource();//获得一些资源，返回一个对象
        System.out.println(field.getText());//获得输入框的文本
    }
}